import request from '../utils/request';


export async function fetchAppointment(shopId, status) {
  return await request('/appointmentFetch', {
    params: { filter: JSON.stringify({
      shopId,
      status,
    }),
    },
  });
}

export function submitAppointment(param) {
  return request('/appointmentResult',
    {
      method: 'post',
      body: { ...param },
    },
  );
}


export async function fetchAppointmentResult(shopId, card_no) {
  return await request('/appointmentResultFetch', {
    params: { filter: JSON.stringify({
      shopId, card_no,
    }),
    },
  });
}

export function cancelAppointment(_id, status) {
  console.log(_id, status);
  return request(`/appointmentResult/${_id}`, {
    method: 'put', body: { status },
  });
}

export async function fetchCurrentVip(shopId, card_no) {
  return await request('/fetchVip', {
    params: { filter: JSON.stringify({
      shopId,
      card_no,
    }),
    },
  });
}


export async function checkApplyStatus(serviceId, shopId, branch_no, card_no, apply_time) {
  return await request('/appointmentResultCheck', {
    params: { filter: JSON.stringify({
      serviceId,
      shopId,
      branch_no,
      card_no,
      apply_time,
    }),
    },
  });
}

